using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Gencode.PrsCommon.App;

namespace Personalplaner
{
    [ToolboxItem(false)]
    public partial class OptionsArbeitsZeitData : Gencode.Gengui.GUControl/* UserControl*/, IOptionsInterface
    {
        bool changed = false;

        public OptionsArbeitsZeitData()
        {
            InitializeComponent();
            setOptions();
        }

        public void save()
        {
            if (changed)
            {
                //SaveOptions saveOp = new SaveOptions();
                //saveOp.SaveData("Arbeitszeitprotag", 0, (double)numStdPTag.Value);
                //saveOp.SaveData("Arbeitszeitprowoche", 0, (double)numStdPWoche.Value);
                //saveOp.SaveData("Ferientage", 0, (double)numFerienPJahr.Value);

                SaveOptions.SaveData("Arbeitszeitprotag", 0, (double)numStdPTag.Value, "");
                SaveOptions.SaveData("Arbeitszeitprowoche", 0, (double)numStdPWoche.Value, "");
                SaveOptions.SaveData("Ferientage", 0, (double)numFerienPJahr.Value, "");

                double check = 0;
                if (chekcShowDif.Checked) { check = 1; } else { check = 0; }
                SaveOptions.SaveData("PrintOptions", 1, check, "Differenz andrucken");

                if (checkShowSoll.Checked) { check = 1; } else { check = 0; }
                SaveOptions.SaveData("PrintOptions", 2, check, "Soll andrucken");

                if (checkShowHaben.Checked) { check = 1; } else { check = 0; }
                SaveOptions.SaveData("PrintOptions", 3, check, "Haben andrucken");

                changed = false;
            }
        }

        private void setOptions()
        {
			numStdPTag.Value = (int)Option.NumberValue("Arbeitszeitprotag", 0);
			numStdPWoche.Value = (int)Option.NumberValue("Arbeitszeitprowoche", 0);
			numFerienPJahr.Value = (int)Option.NumberValue("Ferientage", 0);

			bool check = false;
			if ((int)Option.NumberValue("PrintOptions", 1) == 1) { check = true; } else { check = false; }
			chekcShowDif.Checked = check;
			if ((int)Option.NumberValue("PrintOptions", 2) == 1) { check = true; } else { check = false; }
			checkShowSoll.Checked = check;
			if ((int)Option.NumberValue("PrintOptions", 3) == 1) { check = true; } else { check = false; }
			checkShowHaben.Checked = check;

            changed = false;
        }

        public bool checkIfChanged()
        {
            return changed;
        }

        private void numStdPTag_ValueChanged(object sender, EventArgs e)
        {
            changed = true;
        }

        private void numStdPWoche_ValueChanged(object sender, EventArgs e)
        {
            changed = true;
        }

        private void numFerienPJahr_ValueChanged(object sender, EventArgs e)
        {
            changed = true;
        }

		private void chekcShowDif_CheckedChanged(object sender, EventArgs e)
		{
			changed = true;
		}

		private void checkShowSoll_CheckedChanged(object sender, EventArgs e)
		{
			changed = true;
		}

		private void checkShowHaben_CheckedChanged(object sender, EventArgs e)
		{
			changed = true;
		}
    }
}
